import { DataNode } from 'antd/es/tree';

import { BasicStatus, MenuType } from './enum';

export interface ListData<T> {
  count: number;
  data: T[];
}

export interface UserToken {
  accessToken?: string;
  refreshToken?: string;
}

export interface UserInfo {
  position?: any;
  treeData?: DataNode[];
  collectingUser?: any;
  promoters?: any;
  roles?: Role[];
  id: string;
  name: string;
  wechatName?: string;
  createAt?: number[];
  gender?: string;
  email?: { option?: string };
  permissions?: Menu[];
  mobile?: { option?: string };
  selectedID?: [number];
  status?: BasicStatus;
  portrait?: string;
  code?: string;
  meta?: any;
  remark?: string;
}

export interface Organization {
  id: number;
  code: string;
  name: string;
  status: 'ENABLE' | 'DISABLE';
  desc?: string;
  order?: number;
  children?: Organization[];
}

export interface Menu {
  id?: number;
  parent?: Menu;
  name: string;
  type: MenuType;
  route: string;
  status?: BasicStatus;
  operation?: Operation;
  operationArray?: string[];
  sort?: number;
  icon?: string;
  component?: string;
  isHidden?: boolean;
  hideTab?: boolean;
  frameSrc?: string;
  newFeature?: boolean;
  children?: Menu[];
}

export interface Module {
  module: string;
  name?: string;
}

export interface Entity {
  entity: string;
  name?: string;
  module: Module;
}

export interface Permission {
  id?: number;
  name: string;
  module?: Module;
  isImmutable: boolean;
  rules?: Menu[];
}

export interface Operation {
  entity: Entity;
  code: string;
  name?: string;
}

export interface Rule {
  id?: number;
  permission?: Permission;
  operation: Operation;
}

export interface Role {
  id: number;
  code?: string;
  name: string;
  status: BasicStatus;
  createAt: number[];
  createBy?: UserInfo;
  remark?: string;
}

export interface Order {
  collectingUser: { id: number; name: string };
  payments?: unknown;
  id?: number;
  code?: string;
  name?: string;
  status?: BasicStatus;
  createAt?: number[];
  createBy?: UserInfo;
}

// /management/comment_label
export interface CommentLabelType {
  id?: number;
  label: string;
}

export interface CascaderOption {
  value?: string | number | null;
  label: React.ReactNode;
  children?: CascaderOption[];
  isLeaf?: boolean;
}

type MyFunctionType = (value?: any) => void;

export interface ModalProps<T> {
  formValue: T;
  title: string;
  show: boolean;
  onOk: VoidFunction | MyFunctionType;
  onCancel: VoidFunction;
}

export interface SearchFormProps {
  onOk: (values: any) => void;
  onReset: VoidFunction;
}

export interface PageForm {
  page: number;
  take: number;
}

export interface BusinessLog {
  major: string;
  action: string;
  memo: string;
  createAt: string;
  operator: UserInfo;
  attachments: string;
}
